MEASUREMENT
COORDINATE MUTATION
TRANSFORMATION
FEATURE_CONVERSION
MISC
HELPER
RANDOM
GRIDS
AGGREGATION
META
ASSERTIONS
BOOLEANS
UNIT CONVERSION
DATA
JOINS
CLASSIFICATION

flip

The flip function is used to flip the order of coordinates of a GeoJSON geometry object.

Parameters

Parameter Type Description
geojson GeoJSON The input GeoJSON geometry object to flip its coordinates.

Return Value

The function returns a new GeoJSON geometry object with the flipped coordinates.

Example

var point = {
  "type": "Point",
  "coordinates": [10, 20]
};

var flippedPoint = turf.flip(point);

console.log(flippedPoint);
// Output: { "type": "Point", "coordinates": [20, 10] }

Note

The flip function only flips the order of coordinates of the given GeoJSON geometry object. To flip the coordinates of a Feature or FeatureCollection, the map function can be used to apply the flip function to each geometry object.

Reference